package com.crscd.ai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 9/29/25 4:50 PM
 * @modifiedBy:
 * @version: 1.0
 */
@RestController
public class ChatClientControllerV2 {
  @Autowired private ChatClient chatClient;

  @GetMapping("/chatclientv2/doChat")
  public String doChat(@RequestParam(name = "msg", defaultValue = "2加9等于几") String msg) {
    final String result = chatClient.prompt().user(msg).call().content();
    System.out.println(result);
    return result;
  }
}
